"""For sending messages to owners of program

This library will send announcement messages to the owner of the household.
Perhaps this functionality could be merged with the logging details."""

import smtplib
import logging
import log

log = logging.getLogger()

SERVER = 'smtp.sasktel.net'
USER = "hepting3"
PASSWORD = "changeme"

def send_txt(msg="Hello.", addr="3065314599@sms.sasktel.com", from_addr="hepting3@sasktel.net"):
    """Sends a message to a user's mobile phone"""

    log.info("Sending sms message to %s" % addr)
    send_mail(msg, addr, from_addr)


def send_mail(msg="Current Stats:", addr="", from_addr="hepting3@sasktel.net"):
    """Sends a message to a users email account"""
    
    header = ("From: %s\r\nTo: %s\r\n\r\n" % (from_addr, addr))
    
    full_message = header + msg
    
    server = smtplib.SMTP(SERVER)
    server.set_debuglevel(1)
    log.debug("Logging in to %s as %s" % (SERVER, USER))
    server.login(USER, PASSWORD)
    log.info("Sending email message to %s" % addr)
    server.sendmail(from_addr, addr, full_message)
    server.quit()

if __name__ == '__main__':
    send_txt()  